Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Seeks for dependency references in JS/TS code
Dep extraction is a common task for many tools solved in different ways from regexps to AST parsing. This implementation relies on streams to make controllable memory consumption.
Working draft
npm i depseek
import fs from 'fs'
import {depseek} from 'depseek'
const stream = fs.createReadStream('index.js')
const deps = await depseek(stream)
// returns
[
{ type: 'dep', value: 'node:fs', index: 17 },
{ type: 'dep', value: 'foo', index: 34 },
{ type: 'dep', value: 'q', index: 92 }
// ...
]
By default depseek
extracts only require
and import
arguments. You can also capture bound comments.
const depsAndComments = await depseek(stream, {comments: true})
[
{ type: 'dep', value: 'node:fs', index: 17 },
{ type: 'dep', value: 'foo', index: 34 },
{ type: 'comment', value: ' @1.0.0', index: 46 }
//...
]
Stream buffer size set to 1000
by default. You can change the limit by passing bufferSize
.
const deps = await depseek(stream, {bufferSize: 10000})
Streams are aimed at intensive bulk operations. If you need to process just a few files, you can use depseekSync
.
import fs from 'node:fs'
import { depseekSync } from 'depseek'
const contents = fs.readFileSync('index.js', 'utf8')
const deps = depseekSync(contents)
patchRefs
The one more utility is patchRefs
that replaces dependency references with a given value.
import {patchRefs} from 'depseek'
const patcher = (v: string) => v.startsWith('.') ? v + '.js' : v
const input = `
import {foo} from './foo'
import {bar} from "./bar"
import {baz} from 'baz'
`
patchRefs(input, patcher)
// gives as a result:
`
import {foo} from './foo.js'
import {bar} from "./bar.js"
import {baz} from 'baz'
`
FAQs
Seeks for dependency references in JS/TS code
We found that depseek demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.